using System;

class FromIntegerIValueofbitP
{
	static void Main()
	{
		//Write a boolean expression that returns if the bit at position p (counting from 0)
		//in a given integer number v has value of 1. Example: v=5; p=1 false.

		//How to get the bit at position p in a number n?
		//int p = 5;
		//int n = 35; // 00000000 00100011
		//int mask = 1 << p; // 00000000 00100000
		//int nAndMask = n & mask; // 00000000 00100000
		//int bit = nAndMask >> p; // 00000000 00000001
		//Console.WriteLine(bit); // 1
		
		
		//Counting from 0 1 2 3 4 5... 
		Console.WriteLine("Which position:");
		int position = Int32.Parse(Console.ReadLine());
		//position -= 1;
		Console.WriteLine("In what number:");
		int number = Int32.Parse(Console.ReadLine());
		int mask = 1 << position;
		int numberAndMask = number & mask;
		int bit = numberAndMask >> position;
		object numberiNBinary = Convert.ToString(number, 2);
		if (bit == 1)
		{
			Console.WriteLine("At Position {0} integer number: {1} = number in binary = {2} ", (position), number, numberiNBinary);
			Console.WriteLine("has value: "+bit);
		}
		else
		{
			Console.WriteLine(numberiNBinary + " at position " + (position) + " \nvalue: "+bit);

		}

	}
}